﻿namespace LxBasic
{
    public struct DiagonalMatrixR3C3
    {
        public DiagonalMatrixR3C3(double a11, double a22, double a33)
        {
            this.a11 = a11;
            this.a22 = a22;
            this.a33 = a33;
        }
        public DiagonalMatrixR3C3(double d)
        {
            this.a11 = d;
            this.a22 = d;
            this.a33 = d;
        }
        public double a11;
        public double a22;
        public double a33;
        public void Inverse()
        {
            a11 = 1 / a11;
            a22 = 1 / a22;
            a33 = 1 / a33;
        }
        public static DiagonalMatrixR3C3 operator +(DiagonalMatrixR3C3 a, DiagonalMatrixR3C3 b)
        {
            return new DiagonalMatrixR3C3(a.a11 + b.a11, a.a22 + b.a22, a.a33 + b.a33);
        }
        public static DiagonalMatrixR3C3 operator -(DiagonalMatrixR3C3 a, DiagonalMatrixR3C3 b)
        {
            return new DiagonalMatrixR3C3(a.a11 - b.a11, a.a22 - b.a22, a.a33 - b.a33);
        }
        public static DiagonalMatrixR3C3 operator -(DiagonalMatrixR3C3 a)
        {
            return new DiagonalMatrixR3C3(-a.a11, -a.a22, -a.a33);
        }
        public static DiagonalMatrixR3C3 operator *(double d, DiagonalMatrixR3C3 v)
        {
            return new DiagonalMatrixR3C3(v.a11 * d, v.a22 * d, v.a33 * d);
        }
        public static DiagonalMatrixR3C3 operator *(DiagonalMatrixR3C3 v, double d)
        {
            return new DiagonalMatrixR3C3(v.a11 * d, v.a22 * d, v.a33 * d);
        }
        public MatrixR3C3 ToMatrixR3C3()
        {
            return new MatrixR3C3(
                a11, 0, 0,
                0, a22, 0,
                0, 0, a33);
        }
        public override string ToString()
        {
            return ToMatrixR3C3().ToString();
        }
        public static DiagonalMatrixR3C3 DiagnalMatrix1 { get => _DiagnalMatrix1; }
        private static DiagonalMatrixR3C3 _DiagnalMatrix1 = new DiagonalMatrixR3C3(1, 1, 1);
    }
}
